﻿<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>TICK</title>
    <script type="text/javascript" src="../../ac_conf.js"></script>
    <script type="text/javascript" src="../../ac.min.js"></script>
    <style type="text/css">
        body {
            font-family: Verdana, Geneva, Tahoma, sans-serif;
            font-size: 9pt;
            background-color: rgb(199, 237, 204);
            overflow: scroll;
        }
    </style>
</head>

<body>
    <strong>Tick Debug Window</strong>&emsp;
    &emsp;<a href="javascript:fdapi.tag.delete(id)">DeleteTag</a>
    &emsp;<a href="javascript:ue.internal.postevent('test string')">PostEvent</a>
    &emsp;<a href="javascript:fdapi.showTickWindow(false);">Close</a>
    <hr>
    <span id="r1"></span>
    <hr>
    <span id="r2"></span>
    <hr>
    <span id="r3"></span>
</body>

</html>

<script>
    var id = 'testTag';
    var i = 0;

    var data = {
        id: id,
        coordinate: [493217, 2491901, -1.9],
        text: 'Tag:0',
        textSize: 20,
        textColor: Color.Yellow,
        range: [1, 10000],
        showLine: false
    }

    window.onload = function () {
        new DigitalTwinAPI();
        fdapi.tag.delete(id);
        fdapi.tag.add(data, o => {
            document.getElementById('r3').innerText = 'tag created.'
            fdapi.tag.focus(id, 100, 0);
        });
    }

    function clientCalled(str) {
        document.getElementById('r3').innerText = str;
    }

    function tick(frame) {
        let data = fdapi.tag.setText(id, 'Tag:' + (i++).toString(), null);
        document.getElementById('r1').innerText = `[Frame:${frame}] ` + JSON.stringify(data);
    }

    function tick_next(o, frame) {
        if (o.command == CommandType.Tag_Update) {
            fdapi.tag.get(id, null);
        }
        else if (o.command == CommandType.Tag_Get) {
            document.getElementById('r2').innerText = `[Frame:${frame}] ` + JSON.stringify(o);
        }
    }

</script>